<template>
  <div>
    <el-card>
      <div slot="header">
        <div class="m-b">
          <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/userManage' }">用户管理</el-breadcrumb-item>
            <el-breadcrumb-item>用户详情</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
      </div>
      <el-form label-width="120px" class="el-form" :model="formData" label-position="right">
        <!--<el-form-item label="设备ID">{{formData.platformId}}</el-form-item>-->
        <el-form-item label="用户名称">{{formData.name}}</el-form-item>
        <el-form-item label="用户别名">{{formData.displayName}}</el-form-item>
        <el-form-item label="用户类型">{{formData.type}}</el-form-item>
        <el-form-item label="建筑类型">
          <span v-if="formData.buildType == 'HOSPITAL'">医院</span>
          <span v-if="formData.buildType == 'OFFICE'">办公楼</span>
        </el-form-item>
        <el-form-item label="平台描述">{{formData.description}}</el-form-item>
        <el-form-item label="创建时间">{{formData.createTime | dateFormat}}</el-form-item>
        <el-form-item label="更新时间">{{formData.updateTime | dateFormat}}</el-form-item>
        <el-form-item label="平台LOGO">
          <img v-if="logo != ''" :src="logo" style="width: 300px; height: 300px;"/>
        </el-form-item>
        <el-form-item style="text-align: center">
          <el-button type="default" size="mini" icon="el-icon-back" @click="goBack">返回</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
/*import { details } from "@/api/userManage";*/
import {getImg} from "@/api/common";
import {formatDate} from "@/utils/utils";

export default {
  name: "userView",
  data() {
    return {
      platformId: "",
      formData: {},
      projectOptions: [],
      imageUrl: "",
      logo: "",
      projectName: ""
    };
  },
  filters: {
    dateFormat(column) {
      return formatDate(new Date(column));
    }
  },
  created() {
    this.platformId = this.$route.query.platformId;
  },
  mounted() {
    this.getMessage();
  },
  methods: {
    getMessage() {
      const that = this;
      let data = {
        platformId: this.platformId
      };
      details(data).then(res => {
        if (res["code"] == 200) {
          that.formData = res.value;
          if (res.value.logoImage != null) {
            let data = {
              key: res.value.logoImage
            };
            getImg(data).then(res => {
              if (res["code"] == 200) {
                that.logo = res.value;
              }
            });
          }
        }
      });
    },
    goBack() {
      this.$router.push("/platformManage");
    }
  }
};
</script>

<style scoped>
.el-form {
  width: 90%;
  margin: 20px;
}
</style>
